//    Copyright (C) Kherty.  All rights reserved.
using System.Windows.Media;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class ScRgbColor : ColorBase
    {
        private float b;
        private float g;
        private float r;

        protected override Color ResolveRawColor(ColorScheme colorScheme)
        {
            return Color.FromScRgb(1, r/100000, g/100000, b/100000);
        }

        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("scrgbClr"))
            {
                r = c.GetFloat("r");
                g = c.GetFloat("g");
                b = c.GetFloat("b");
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("scrgbClr"))
            {
                c.SetFloat("r", r);
                c.SetFloat("g", g);
                c.SetFloat("b", b);
            }
        }
    }
}